﻿using System;
using NBpn.Network;

namespace NBpn.TransferFunction
{
    public class SigmoidalTransferFuncion : AbstractTransferFunction
    {
        public override double Evaluate(INet net)
        {
            return 1/(1 + ePow(-net.Value));
        }

        public override double Derivate(INet net)
        {
            double y = Evaluate(net);

            return y*(1 - y);
        }

        private double ePow(double x)
        {
            return Math.Pow(Math.E, x);
        }
    }
}